<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="js/common.js" charset="utf-8"></script>

<script type="text/javascript">
function ajaxObjAswList(sId, pId, list){
	var url = "registPollObjAswList.json";
	$.ajax({
		type: 		"POST"
		,url: 		url
		,dataType:	"json"
		,data:		"pollId=" + pId + "&objAswList=" + list + "&ptId=" + sId
		,async:		false
		,success: 	function(data){
						debug.html("insert success")
					}
		,error: 	function(){
						debug.html("ajax error");
					}
	});	
}

function insertObjListTest() {
	var pollId = "1";
	var ptId = "1";
	var list = [{"a" : "1"}
				, {"b" : "2"}
				, {"c" : "3"}
				];
	var listStr = JSON.stringify(list);
	ajaxObjAswList(ptId, pollId, listStr);
}



function ajaxSubAsw(sId, pId, avatarId, val){
	var url = "registPollSubAsw.json";
	$.ajax({
		type: 		"POST"
		,url: 		url
		,dataType:	"json"
		,data:		"pollId=" + pId + "&avatarId=" + avatarId + "&ptId=" + sId + "&aswVal=" + val
		,async:		false
		,success: 	function(data){
						debug.html("insert success")
					}
		,error: 	function(){
						debug.html("ajax error");
					}
	});	
}

function insertSubListTest() {
	var pollId = "1";
	var ptId = "1";
	var avatarId = "a";
	var aswVal = "abcde";
	ajaxSubAsw(ptId, pollId, avatarId, aswVal);
}
</script>
</head>
<body>
<button onclick="insertObjListTest();">Obj Insert Test</button>
<button onclick="insertSubListTest();">Sub Insert Test</button>
</body>
</html>